package controllers;

import play.*;
import play.modules.siena.SienaFixtures;
import play.mvc.*;
import play.test.Fixtures;

import java.util.*;

import com.google.appengine.api.users.UserService;

import models.*;

public class Application extends Controller {

	public static void index() {
	//	SienaFixtures.deleteDatabase();
		if (User.findAllUsers().isEmpty()) {
			User fouda = new User("Fufu", "password", new Date(),
					"fouda@gmail.com");
			fouda.save();

			User lama = new User("Lolo", "password", new Date(),
					"lama@gmail.com");
			lama.save();
			User marwan = new User("Maro", "password", new Date(),
					"marwan@gmail.com");
			marwan.save();

			Template testTemp = new Template("test");
			testTemp.tabs.add(new Integer(1));
			testTemp.tabs.add(new Integer(2));
			testTemp.save();
			// System.out.println(Template.getCount() + "TemplateCount");

			ArrayList<Long> admins = new ArrayList<Long>();
			admins.add(lama.getId());
			Event goldfishEvent = new Event(testTemp, admins, "goldfish");
			// System.out.println(goldfishEvent.getAdmins().size() + "<<<<<<");
			goldfishEvent.save();
			// System.out.println(Event.getCount() + "EventCount");
			 System.out.println(User.getCount() + " UserCount");

		}
		List<User> users = User.findAllUsers();
		List<Event> events = Event.all().fetch() ;
		User.getAll().filter("userName", "Lolo").delete();
		render(users,events);

	}
	public static void deleteUser(){
		
	}
}